import 'package:flutter/material.dart';
import './state_management_demo.dart';
import './state_model_demo.dart';

class StateListDemo extends StatelessWidget {
  const StateListDemo({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('StateListDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(5.0),
        child: ListView(
          children: <Widget>[
            ItemBuilderDemo('StateManagerDemo',page:StateManagementDemo()),
            ItemBuilderDemo('StateModelDemo',page:StateModelDemo()),
          ],
        ),
      ),
    );
  }
}

class ItemBuilderDemo extends StatelessWidget {
  final String title;
  final Widget page;

  ItemBuilderDemo (
    this.title,{
    this.page
  });

  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(title),
      onTap: (){
        Navigator.of(context).push(
          MaterialPageRoute(builder: (context)=>page)
        );
      },
    );
  }

}